<template>
  <div class="newest-box">
    <div class="label-names martop">最热新游</div>
    <div>
      <div v-for="(item, index) in 5" :key="index">
        <div class="newimg" :class="{ noneimg: dindex === index }">
          <img
            :src="newList[index].giBackdrop"
            alt=""
            @click="goGame(newList[index].giId)"
          />
        </div>
      </div>
      <div></div>
      <div class="snew-all">
        <div
          class="snew-item"
          v-for="(item, index) in 5"
          :key="index"
          @click="goGame(newList[index].giId)"
          @mouseenter="changImg(index)"
          :class="{ overitem: dindex === index }"
        >
          <div class="triangle" :class="{ noneimg: dindex === index }"></div>
          <div class="snew-img">
            <img :src="newList[index].giLogo" alt="" />
            <div class="snew-text">
              <div>{{ newList[index].giName }}</div>
              <div>{{ newList[index].gtName }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Newest",
  props: {
    newList: {
      type: Array,
    },
  },
  data() {
    return {
      dindex: 0, //显示图片的下标
    };
  },
  methods: {
    changImg(index) {
      this.dindex = index;
    },
    goGame(id) {
      this.$router.push({ name: "详情", params: { id: id } });
    },
  },
};
</script>

<style>
.newest-box {
  width: 80%;
  margin: 0 auto;
}

.martop {
  margin-bottom: 0.15rem;
}

.newimg {
  position: absolute;
  width: 80%;
  height: 1.85rem;
  opacity: 0;
  transition: all 1s;
  cursor: pointer;
}

.newimg img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
}
.snew-all {
  padding-top: 1.85rem;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-around;
}

.snew-all :nth-child(1),
.snew-all :nth-child(2),
.snew-all :nth-child(3),
.snew-all :nth-child(4) {
  margin-right: 3%;
}

.snew-item {
  display: flex;
  flex: 1;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2%;
  border: 2px solid rgb(204, 201, 207);
  border-radius: 10px;
  opacity: 0.3;
  cursor: pointer;
}

.snew-img {
  display: flex;
  flex: 1;
  align-items: center;
}

.snew-img img {
  width: 30%;
  border-radius: 15px;
  margin-top: 5px;
  margin-bottom: 5px;
}

.snew-text {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 5%;
}

.snew-text div:nth-child(1) {
  font-size: 13px;
  margin-bottom: 1%;
}

.triangle {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid rgb(125, 214, 250);
  position: relative;
  top: -0.3rem;
  left: 20%;
  opacity: 0;
}

.noneimg {
  opacity: 1;
  z-index: 9999;
}
.overitem {
  opacity: 1;
  border: 2px solid rgb(125, 214, 250);
}
</style>